
<html>
<title>pygame - Pygame Documentation</title>
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>


<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
<tr>
<td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
	||&nbsp;
	<a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
	<a href=../index.html>Help Contents</a> &nbsp;||
	<a href=index.html>Reference Index</a> &nbsp;||
	<br>&nbsp;<br>
	
<a href=cdrom.html>Cdrom</a>&nbsp;||&nbsp;
<a href=cursors.html>Cursors</a>&nbsp;||&nbsp;
<a href=display.html>Display</a>&nbsp;||&nbsp;
<a href=draw.html>Draw</a>&nbsp;||&nbsp;
<a href=event.html>Event</a>&nbsp;||&nbsp;
<a href=font.html>Font</a>&nbsp;||&nbsp;
<a href=image.html>Image</a>&nbsp;||&nbsp;
<a href=joystick.html>Joystick</a>&nbsp;||&nbsp;
<a href=key.html>Key</a>&nbsp;||&nbsp;
<a href=mixer.html>Mixer</a>&nbsp;||&nbsp;
<a href=mouse.html>Mouse</a>&nbsp;||&nbsp;
<a href=movie.html>Movie</a>&nbsp;||&nbsp;
<a href=music.html>Music</a>&nbsp;||&nbsp;
<a href=overlay.html>Overlay</a>&nbsp;||&nbsp;
<a href=pygame.html>Pygame</a>&nbsp;||&nbsp;
<a href=rect.html>Rect</a>&nbsp;||&nbsp;
<a href=scrap.html>Scrap</a>&nbsp;||&nbsp;
<a href=sndarray.html>Sndarray</a>&nbsp;||&nbsp;
<a href=sprite.html>Sprite</a>&nbsp;||&nbsp;
<a href=surface.html>Surface</a>&nbsp;||&nbsp;
<a href=surfarray.html>Surfarray</a>&nbsp;||&nbsp;
<a href=time.html>Time</a>&nbsp;||&nbsp;
<a href=transform.html>Transform</a>
</td></tr></table>
<br>


<a name="pygame">
<big><b>pygame</big></b><br><ul>
  <i>the top level pygame package</i><br>
<ul><small><table>
  <tr><td><a href="pygame.html#pygame.init">pygame.init</a> - <font size=-1>initialize all imported pygame modules</font></td><td>initialize all imported pygame modules</td></tr>
  <tr><td><a href="pygame.html#pygame.quit">pygame.quit</a> - <font size=-1>uninitialize all pygame modules</font></td><td>uninitialize all pygame modules</td></tr>
  <tr><td><a href="pygame.html#pygame.error">pygame.error</a> - <font size=-1>standard pygame exception</font></td><td>standard pygame exception</td></tr>
  <tr><td><a href="pygame.html#pygame.get_error">pygame.get_error</a> - <font size=-1>get the current error message</font></td><td>get the current error message</td></tr>
  <tr><td><a href="pygame.html#pygame.get_sdl_version">pygame.get_sdl_version</a> - <font size=-1>get the version number of SDL</font></td><td>get the version number of SDL</td></tr>
  <tr><td><a href="pygame.html#pygame.register_quit">pygame.register_quit</a> - <font size=-1>register a function to be called when pygame quits</font></td><td>register a function to be called when pygame quits</td></tr>
  <tr><td><a href="pygame.html#pygame.version">pygame.version</a> - <font size=-1>small module containing version information</font></td><td>small module containing version information</td></tr>
</table></small></ul>
<p>The pygame package represents the top-level package for others to use. Pygame itself is broken into many submodules, but this does not affect programs that use Pygame. </p>
<p>As a convenience, most of the top-level variables in pygame have been placed inside a module named <tt>'pygame.locals'</tt>. This is meant to be used with 'from <tt>pygame.locals</tt> import *', in addition to 'import pygame'. </p>
<p>When you 'import pygame' all available pygame submodules are automatically imported. Be aware that some of the pygame modules are considered "optional", and may not be available. In that case, Pygame will provide a placeholder object instead of the module, which can be used to test for availability. </p>
<!--COMMENTS:pygame--> &nbsp;<br> 


<a name="pygame.init">
<big><b>pygame.init</big></b><br><ul>
  <i>initialize all imported pygame modules</i><br>
  <tt>pygame.init(): return (numpass, numfail)</tt><br>
<p>Initialize all imported Pygame modules. No exceptions will be raised if a module fails, but the total number if successful and failed inits will be returned as a tuple. You can always initialize individual modules manually, but <tt>pygame.init</tt> is a convenient way to get everything started. The init() functions for individual modules will raise exceptions when they fail. </p>
<p>You may want to initalise the different modules seperately to speed up your program or to not use things your game does not. </p>
<p>It is safe to call this init() more than once: repeated calls will have no effect. This is true even if you have <tt><a href="pygame.html#pygame.quit">pygame.quit</a> - <font size=-1>uninitialize all pygame modules</font></tt> all the modules. </p>
<!--COMMENTS:pygame.init--> &nbsp;<br> 
<br></ul>


<a name="pygame.quit">
<big><b>pygame.quit</big></b><br><ul>
  <i>uninitialize all pygame modules</i><br>
  <tt>pygame.quit(): return None</tt><br>
<p>Uninitialize all pygame modules that have previously been initialized. When the Python interpreter shuts down, this method is called regardless, so your program should not need it, except when it wants to terminate its pygame resources and continue. It is safe to call this function more than once: repeated calls have no effect. </p>
<p>Note, that <tt>pygame.quit</tt> will not exit your program. Consider letting your program end in the same way a normal python program will end. </p>
<!--COMMENTS:pygame.quit--> &nbsp;<br> 
<br></ul>


<a name="pygame.error">
<big><b>pygame.error</big></b><br><ul>
  <i>standard pygame exception</i><br>
  <tt>raise pygame.error, message</tt><br>
<p>This exception is raised whenever a pygame or <tt>SDL</tt> operation fails. You can catch any anticipated problems and deal with the error. The exception is always raised with a descriptive message about the problem. </p>
<p>Derived from the RuntimeError exception, which can also be used to catch these raised errors. </p>
<!--COMMENTS:pygame.error--> &nbsp;<br> 
<br></ul>


<a name="pygame.get_error">
<big><b>pygame.get_error</big></b><br><ul>
  <i>get the current error message</i><br>
  <tt>pygame.get_error(): return errorstr</tt><br>
<p><tt>SDL</tt> maintains an internal error message. This message will usually be given to you when <tt>pygame.error</tt> is raised. You will rarely need to call this function. </p>
<!--COMMENTS:pygame.get_error--> &nbsp;<br> 
<br></ul>


<a name="pygame.get_sdl_version">
<big><b>pygame.get_sdl_version</big></b><br><ul>
  <i>get the version number of SDL</i><br>
  <tt>pygame.get_sdl_version(): return major, minor, patch</tt><br>
<p>Returns the three version numbers of the <tt>SDL</tt> library. This version is built at compile time. It can be used to detect which features may not be available through Pygame. </p>
<p>get_sdl_version is new in pygame <tt>1.7.0</tt> </p>
<!--COMMENTS:pygame.get_sdl_version--> &nbsp;<br> 
<br></ul>


<a name="pygame.register_quit">
<big><b>pygame.register_quit</big></b><br><ul>
  <i>register a function to be called when pygame quits</i><br>
  <tt>register_quit(callable): return None</tt><br>
<p>When <tt>pygame.quit</tt> is called, all registered quit functions are called. Pygame modules do this automatically when they are initializing. This function is not be needed for regular pygame users. </p>
<!--COMMENTS:pygame.register_quit--> &nbsp;<br> 
<br></ul>


<a name="pygame.version">
<big><b>pygame.version</big></b><br><ul>
  <i>small module containing version information</i><br>
  <tt>module pygame.version</tt><br>
<ul><small><table>
  <tr><td><a href="pygame.html#pygame.version.ver">pygame.version.ver</a> - <font size=-1>version number as a string</font></td><td>version number as a string</td></tr>
  <tr><td><a href="pygame.html#pygame.version.vernum">pygame.version.vernum</a> - <font size=-1>tupled integers of the version</font></td><td>tupled integers of the version</td></tr>
</table></small></ul>
<p>This module is automatically imported into the pygame package and offers a few variables to check with version of pygame has been imported. </p>
<!--COMMENTS:pygame.version--> &nbsp;<br> 


<a name="pygame.version.ver">
<big><b>pygame.version.ver</big></b><br><ul>
  <i>version number as a string</i><br>
  <tt>pygame.version.ver = "1.2"</tt><br>
<p>This is the version represented as a string. It can contain a micro release number as well, <tt>e.g.</tt>, <tt>"1.5.2"</tt> </p>
<!--COMMENTS:pygame.version.ver--> &nbsp;<br> 
<br></ul>


<a name="pygame.version.vernum">
<big><b>pygame.version.vernum</big></b><br><ul>
  <i>tupled integers of the version</i><br>
  <tt>pygame.version.vernum = (1, 5, 3)</tt><br>
<p>This variable for the version can easily be compared with other version numbers of the same format. An example of checking Pygame version numbers would look like this: </p>
<pre>    if pygame.version.vernum < (1, 5):
        print "Warning, older version of Pygame (%s)" %  pygame.version.ver
        disable_advanced_features = True
</pre>
<!--COMMENTS:pygame.version.vernum--> &nbsp;<br> 
<br></ul>
<br></ul>
<br></ul>

</body></html>
